package com.vgooo.util;


import com.vgooo.client.R;
import com.vgooo.client.VGActivity;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.AlertDialog.Builder;
import android.content.Context;
import android.os.Handler;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.LinearInterpolator;
import android.widget.ImageView;
import android.widget.ProgressBar;

public class SimpleLoading {
		
	public static Progress startProgress(Activity context){
		Progress progress = new Progress();
		View view = LayoutInflater.from(context).inflate(R.layout.simple_loading, null);
		ProgressBar progressBar = (ProgressBar) view.findViewById(R.id.simple_loading_progressBar1);
		context.addContentView(view, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
		progress.startAnimation(view);
		return progress;
	}
	
	public static Progress startProgress(View view){
		Progress progress = new Progress();
		progress.startAnimation(view);
		return progress;
	}
	
	 public static class Progress{
		private boolean isLoading ;
		private View view;
		
		private void startAnimation(final View view ){
			this.view = view ;
			this.isLoading = true ;
		}
		
		
		public boolean isLoading() {
			return isLoading;
		}

//		public void setLoading(boolean isLoading) {
//			this.isLoading = isLoading;
//		}


		public void start(){
			if(view!=null){
				view.setVisibility(View.VISIBLE);
			}
			this.isLoading = true ;
		}
		
		public  void cancel(){
			if(view!=null){
				view.setVisibility(View.GONE);
			}
			this.isLoading = false ;
		}
		
	}

}
